<!DOCTYPE html>
<html>
<head>
    <title>文件上传</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" href="../../css/font-awesome.min.css">
    <link rel="stylesheet" href="../../plugins/jqgrid/ui.jqgrid-bootstrap.css">
    <link rel="stylesheet" href="../../plugins/ztree/css/metroStyle/metroStyle.css">
    <link rel="stylesheet" href="../../css/bootstrap-table.min.css">
    <link rel="stylesheet" href="../../css/main.css">
    <link rel="stylesheet" href="../../plugins/treegrid/jquery.treegrid.css">

    <script src="../../libs/jquery.min.js"></script>
    <script src="../../plugins/layer/layer.js"></script>
    <script src="../../libs/bootstrap.min.js"></script>
    <script src="../../libs/vue.min.js"></script>
    <script src="../../libs/bootstrap-table.min.js"></script>
    <script src="../../plugins/treegrid/jquery.treegrid.min.js"></script>
    <script src="../../plugins/treegrid/jquery.treegrid.bootstrap3.js"></script>
    <script src="../../plugins/treegrid/jquery.treegrid.extension.js"></script>
    <script src="../../plugins/treegrid/tree.table.js"></script>
    <script src="../../plugins/jqgrid/grid.locale-cn.js"></script>
    <script src="../../plugins/jqgrid/jquery.jqGrid.min.js"></script>
    <script src="../../plugins/ztree/jquery.ztree.all.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/layui.js" charset="utf-8"></script>
</head>
<style type="text/css">
    hr.hr1 {
        border: 1px solid #e0d5d5;
        width: 5%;
        margin-left: inherit;
        margin-top: 44px;
        float: left;
    }
    span.s1 {
        font-size: 18px;
        margin-left: 5px;
        float: left;
        margin-top: 30px;
    }
    hr.hr2 {
        border: 1px solid #e0d5d5;
        width: 83%;
        margin-left: inherit;
        margin-top: 44px;
        float: right;
    }/*hr.hr3 {
        border: 1px solid #e0d5d5;
        width: 86%;
        margin-left: inherit;
        margin-top: 44px;
        float: right;
    }*/
    .col00 {
        /* float: left; */
        width: 70%;
        padding-left: 190px;
        padding-top: 100px;
    }
    .col22 {
        width: 20%;
        float: left;
        font-size: 16px;
        text-align: right;
        padding-top: 30px;
    }
    .col33 {
        float: left;
        width: 70%;
        padding-left: 20px;
        padding-top: 25px;
    }
    .col44 {
        float: left;
        width: 70%;
        padding-left: 190px;
        padding-top: 50px;
    }
    .form-horizontal {
        width: 850px;
        padding-top: 20px;
    }
</style>
<body >

<div id="rrapp">
    <div class="rop">



        <hr class="hr1"><span class="s1">上传项目文件</span><hr class="hr2">
        <form class="form-horizontal" enctype=multipart/form-data>
                <div class="form-gr11">
                    <div class="col22">data.zip,photo.zip：</div>
                    <div class="col33">
                        <input type="file" class="form-control"  id="selfiles1" accept=".zip,.txt" multiple="multiple" />
                    </div>
                </div>

            <div class="form-gr11">
                <div class="col44">
                    <input type="button" class="btn btn-primary" value="上传项目文件" onclick="uploadFile()"/>
                </div>
            </div>
        </form>
    </div>
</div>
<script>




    /**
     *    上传文件
     */
    function uploadFile() {
        var url = "fileLogin/importProject";
        var filrarr1 = document.getElementById("selfiles1").files;
//        var filrarr2 = document.getElementById("selfiles2").files;
//        var filrarr3 = document.getElementById("selfiles3").files;
        var formdata = new FormData();//创建一个表单

        var index = layer.load();

        for(var i = 0; i < filrarr1.length; i++){
            formdata.append("files", filrarr1[i]);
        }
//        for(var i = 0; i < filrarr2.length; i++){
//            formdata.append("files", filrarr2[i]);
//        }for(var i = 0; i < filrarr3.length; i++){
//            formdata.append("files", filrarr3[i]);
//        }

        $.ajax({
            type: "POST",
            url: baseURL + url,
            data: formdata,
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'json',
            success: function(r) {
                if (r.code == 0) {
                    layer.close(index);
                    layer.msg("上传成功")
                }else{
                    layer.close(index);
                    layer.msg(r.msg);
                }
            },
            error: function(error) {
                layer.msg("未知错误");
            }
        });
    }
</script>
</body>
</html>